package com.example.cafe.work.model;

public  enum StateEnum {
    // 订单状态
    PENDING_PAYMENT(1, "待支付"),
//    PAID(2, "已支付"),
    IN_PROGRESS(3, "制作中"),
    COMPLETED(4, "已完成"),
    CANCELLED(5, "已取消"),

    // 商品状态
    ON_SALE(6, "在售"),
    SOLD_OUT(7, "售完"),
    NOT_ON_SHELF(8, "未上架"),
    HAVING_USE(11,"已核销"),

    // 优惠券类型
    NORMAL_COUPON(9, "普通劵"),
    TIME_LIMITED_COUPON(10, "限时劵");

    private final int stateId;
    private final String stateName;

    StateEnum(int stateId, String stateName) {
        this.stateId = stateId;
        this.stateName = stateName;
    }

    public int getStateId() {
        return stateId;
    }

    public String getStateName() {
        return stateName;
    }

    public static StateEnum fromStateId(int stateId) {
        for (StateEnum state : values()) {
            if (state.getStateId() == stateId) {
                return state;
            }
        }
        throw new IllegalArgumentException("Unknown state id: " + stateId);
    }

    public static String getStateNameById(int stateId) {
        StateEnum state = fromStateId(stateId);
        return state.getStateName();
    }
}
